package com.fr.report.cellElement;

import com.fr.base.core.ComparatorUtils;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.report.painter.BarcodePainter;
import com.fr.report.script.Calculator;

public class BarcodePresent extends AbstractPresent
{
  private BarcodeAttr barcode;

  public BarcodePresent()
  {
  }

  public BarcodePresent(BarcodeAttr paramBarcodeAttr)
  {
    this.barcode = paramBarcodeAttr;
  }

  public BarcodeAttr getBarcode()
  {
    return this.barcode;
  }

  public void setBarcode(BarcodeAttr paramBarcodeAttr)
  {
    this.barcode = paramBarcodeAttr;
  }

  public Object present(Object paramObject, Calculator paramCalculator)
  {
    if ((this.barcode == null) || (paramObject == null))
      return super.present(paramObject, paramCalculator);
    if (paramObject instanceof Formula)
      paramObject = ((Formula)paramObject).getResult();
    return new BarcodePainter(this.barcode, paramObject.toString());
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if ((paramXMLableReader.isChildNode()) && (paramXMLableReader.getTagName().equals("BarcodeAttr")))
    {
      this.barcode = new BarcodeAttr();
      paramXMLableReader.readXMLObject(this.barcode);
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    if (this.barcode != null)
      this.barcode.writeXML(paramXMLPrintWriter);
  }

  public boolean equals(Object paramObject)
  {
    return ((paramObject instanceof BarcodePresent) && (ComparatorUtils.equals(this.barcode, ((BarcodePresent)paramObject).barcode)));
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    BarcodePresent localBarcodePresent = (BarcodePresent)super.clone();
    if (this.barcode != null)
      localBarcodePresent.barcode = ((BarcodeAttr)this.barcode.clone());
    return localBarcodePresent;
  }
}